import 'dart:async';

import 'package:app_links/app_links.dart';
import 'package:example/pages/viewmodel_page.dart';
import 'package:flutter_scaffold/flutter_scaffold.dart';

import '../pages/text_demo_page.dart';

/// android launch:
/// adb shell am start -a android.intent.action.VIEW -d "hzb://ddd.com/#/geoow"
/// @data:2025/7/14
/// @author:zhibo.huang

class DeepLinkService {
  late AppLinks _appLinks;

  Future<void> initDeepLinks() async {
    _appLinks = AppLinks();

    // 监听后续链接（热启动）
     _appLinks.uriLinkStream.listen(_handleDeepLink);
  }

  void _handleDeepLink(Uri uri) {
    Log.i("外部链接跳转:"+uri.toString());
    Get.to(() => TextDemoPage());
    // // 解析通用链接 (Universal Links)
    // if (uri.scheme == 'https' && uri.host == 'hzb.com') {
    //   _handleUniversalLink(uri);
    // }
    // // 解析自定义 Scheme
    // else if (uri.scheme == 'hzb') {
    //   _handleCustomScheme(uri);
    // }
  }

}